from config.all_paths import config_variable_path
from config.global_variable import CZKB
from utils.file_handling.txt_handling import extract_txt


def CZKBDataProcessing(data, res):
    if data.get('case_name') == '操作看板数据统计':
        visitCount = str(res.json()['data']['visitCount'])
        fullVisitCount = str(res.json()['data']['fullVisitCount'])
        isVisitCount = str(res.json()['data']['isVisitCount'])
        visit7P10Count = str(res.json()['data']['visit7P10Count'])
        visit7P25Count = str(res.json()['data']['visit7P25Count'])
        importCount = str(res.json()['data']['importCount'])
        importRate = str(res.json()['data']['importRate'])
        importNumCount = str(res.json()['data']['importNumCount'])
        visitNumCount = str(res.json()['data']['visitNumCount'])
        importNumCountDistinct = str(res.json()['data']['importNumCountDistinct'])
        visitNumCountDistinct = str(res.json()['data']['visitNumCountDistinct'])
        #检查项
        full = str(res.json()['data']['evaluationCountVO']['full']) #全套检查宝宝量
        heightWeight = str(res.json()['data']['evaluationCountVO']['heightWeight']) #身高体重
        boneage = str(res.json()['data']['evaluationCountVO']['boneage']) #骨龄
        stimulateExperiment = str(res.json()['data']['evaluationCountVO']['stimulateExperiment']) #激发试验
        bloodFullSet = str(res.json()['data']['evaluationCountVO']['bloodFullSet']) #血全套
        mri = str(res.json()['data']['evaluationCountVO']['mri']) #MRI
        geneticExamination = str(res.json()['data']['evaluationCountVO']['geneticExamination']) #基因检查
        bultrasound = str(res.json()['data']['evaluationCountVO']['bultrasound']) #B超
        tcmRelated = str(res.json()['data']['evaluationCountVO']['tcmRelated']) #中医相关
        ankle = str(res.json()['data']['evaluationCountVO']['ankle']) #足踝
        bodyAnalysis = str(res.json()['data']['evaluationCountVO']['bodyAnalysis']) #身体成分分析
        boneDensity = str(res.json()['data']['evaluationCountVO']['boneDensity']) #骨密度
        CZKB['visitCount'] = visitCount
        CZKB['fullVisitCount'] = fullVisitCount
        CZKB['isVisitCount'] = isVisitCount
        CZKB['visit7P10Count'] = visit7P10Count
        CZKB['visit7P25Count'] = visit7P25Count
        CZKB['importCount'] = importCount
        CZKB['importRate'] = importRate
        CZKB['importNumCount'] = importNumCount
        CZKB['visitNumCount'] = visitNumCount
        CZKB['importNumCountDistinct'] = importNumCountDistinct
        CZKB['visitNumCountDistinct'] = visitNumCountDistinct




        CZKB['full'] = full
        CZKB['heightWeight'] = heightWeight
        CZKB['boneage'] = boneage
        CZKB['stimulateExperiment'] = stimulateExperiment
        CZKB['bloodFullSet'] = bloodFullSet

        CZKB['mri'] = mri
        CZKB['geneticExamination'] = geneticExamination
        CZKB['bultrasound'] = bultrasound
        CZKB['tcmRelated'] = tcmRelated

        CZKB['ankle'] = ankle
        CZKB['bodyAnalysis'] = bodyAnalysis
        CZKB['boneDensity'] = boneDensity
        extract_txt(config_variable_path, str(CZKB))


    if data.get('case_name') == '外呼相关':
        callCompletingCount = str(res.json()['data']['callCompletingCount']) #虚拟外呼拨通量
        callCount = str(res.json()['data']['callCount']) #虚拟外呼拨号量
        callCompletingRate = str(res.json()['data']['callCompletingRate']) #接通率
        callValidCompletingCount = str(res.json()['data']['callValidCompletingCount']) #虚拟外呼有效拨通量
        callValidCompletingAccountCount = str(res.json()['data']['callValidCompletingAccountCount']) #虚拟外呼有效拨通用户量

        CZKB['callCompletingCount'] = callCompletingCount
        CZKB['callCount'] = callCount
        CZKB['callCompletingRate'] = callCompletingRate
        CZKB['callValidCompletingCount'] = callValidCompletingCount
        CZKB['callValidCompletingAccountCount'] = callValidCompletingAccountCount

    if data.get('case_name') == '跟进记录量':
        childVisitCount = str(res.json()['data']['childVisitCount']) #跟进记录量
        CZKB['childVisitCount'] = childVisitCount

        extract_txt(config_variable_path, str(CZKB))